using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

using SharpCore.Data;

namespace TF.Access
{
    public partial class TF_City
    {
        /// <summary>
        /// Selects all records from the TF_City table.
        /// </summary>
        public static List<TF_City> SelectCityByProvinceId(int pId)
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_City_Select_by_province_id",pId))
            {
                List<TF_City> tF_CityList = new List<TF_City>();
                while (dataReader.Read())
                {
                    TF_City tF_City = MakeTF_City(dataReader);
                    tF_CityList.Add(tF_City);
                }
                return tF_CityList;
            }
        }

        public static List<CityNavigator> SelectCityNavigator(int cityId)
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader("TF_SelectCityNavigator", cityId))
            {
                List<CityNavigator> cityNavigatorList = new List<CityNavigator>();
                while (dataReader.Read())
                {
                    CityNavigator cn = new CityNavigator();
                    if (!dataReader.IsDBNull(0))
                    {
                        cn.CountryId = dataReader.GetInt32(0);
                    }
                    if (!dataReader.IsDBNull(1))
                    {
                        cn.CountryName = dataReader.GetString(1);
                    }
                    if (!dataReader.IsDBNull(2))
                    {
                       cn.CityId = dataReader.GetInt32(2);
                    }
                    if (!dataReader.IsDBNull(3))
                    {
                        cn.CityName = dataReader.GetString(3);
                    }
                    if (!dataReader.IsDBNull(4))
                    {
                        cn.ProvinceId = dataReader.GetInt32(4);
                    }
                    if (!dataReader.IsDBNull(5))
                    {
                        cn.ProvinceName = dataReader.GetString(5);
                    }
                    cityNavigatorList.Add(cn);
                }
                return cityNavigatorList;
            }
        }
    }

    public class CityNavigator
    {
        private int countryId;
        private string countryName;
        private int provinceId;
        private string provinceName;
        private int cityId;
        private string cityName;

        public int CountryId
        {
            get
            {
                return countryId;
            }
            set
            {
                countryId = value;
            }
        }
        public int ProvinceId
        {
            get
            {
                return provinceId;
            }
            set
            {
                provinceId = value;
            }
        }
        public int CityId
        {
            get
            {
                return cityId;
            }
            set
            {
                cityId = value;
            }
        }

        public string CountryName
        {
            get
            {
                return countryName;
            }
            set
            {
                countryName = value;
            }
        }
        public string CityName
        {
            get
            {
                return cityName;
            }
            set
            {
                cityName = value;
            }
        }
        public string ProvinceName
        {
            get
            {
                return provinceName;
            }
            set
            {
                provinceName = value;
            }
        }

    }
}
